package com.weiyuwqj.api.util;

import java.math.BigDecimal;
import java.util.Map;

/**
 * Copyright 2015-2019 Yunfucloud technology co., Ltd.
 * Created by fuxx on 15/12/11.
 */
public class MapUtils {
    public static Object get(Map<String,Object> map,String name){
        Object obj=map.get(name);
        return obj;
    }

    public static BigDecimal getDecimal(Map<String,Object> map,String name){
        Object obj=map.get(name);
        if(obj==null){
            return BigDecimal.ZERO;
        }
        if(obj instanceof Double){
            return BigDecimal.valueOf((Double)obj);
        }
        if(obj instanceof Long){
            return BigDecimal.valueOf((Long)obj);
        }
        if(obj instanceof BigDecimal){
            return (BigDecimal)obj;
        }
        return BigDecimal.ZERO;
    }

}
